package com.barbeque.mall.controller;

import com.barbeque.mall.bean.BasePageInfo;
import com.barbeque.mall.bean.BaseRespVo;
import com.barbeque.mall.bean.param.CommonData;
import com.barbeque.mall.bean.user.*;
import com.barbeque.mall.bean.user.bo.AddressPageBo;
import com.barbeque.mall.bean.user.bo.FeedbackPageInfo;
import com.barbeque.mall.bean.user.bo.FootPrintPageInfo;
import com.barbeque.mall.bean.user.bo.HistoryPageInfo;
import com.barbeque.mall.bean.wx.feedback.WxMarketFeedback;
import com.barbeque.mall.service.user.UsersService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author why
 * @since 2022/07/18 11:58
 */
@RestController
@RequestMapping("admin")
public class UserSController {

    @Autowired
    UsersService usersService;

    /**
     * http://182.92.235.201:8083/admin/address/list?page=1&limit=20&sort=add_time&order=desc
     * 查看收货地址和查询
     *
     * @return
     */
    @RequiresPermissions("admin:address:list")
    @RequestMapping("address/list")
    public BaseRespVo list(AddressPageBo info) {
        CommonData<MarketAddress> data = usersService.selectAddress(info);
        BaseRespVo baseRespVo = BaseRespVo.ok(data);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;
    }

    /**
     * http://182.92.235.201:8083/admin/collect/list?page=1&limit=20&userId=1&valueId=1&sort=add_time&order=desc
     * 查看会员收藏和查询
     *
     * @param userId
     * @param valueId
     * @param info
     * @return
     */
    @RequiresPermissions("admin:collect:list")
    @RequestMapping("collect/list")
    public BaseRespVo list(Integer userId, Integer valueId, BasePageInfo info) {
        CommonData<MarketCollect> data = usersService.selectCollect(userId, valueId, info);
        BaseRespVo baseRespVo = BaseRespVo.ok(data);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;
    }

    /**
     * http://182.92.235.201:8083/admin/footprint/list?page=1&limit=20&sort=add_time&order=desc
     * 查看会员足迹和条件查询
     *
     * @param info
     * @return
     */
    @RequiresPermissions("admin:footprint:list")
    @RequestMapping("footprint/list")
    public BaseRespVo list(FootPrintPageInfo info) {
        CommonData<MarketFootprint> data = usersService.selectFootprint(info);
        BaseRespVo baseRespVo = BaseRespVo.ok(data);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;
    }

    /**
     * http://182.92.235.201:8083/admin/history/list?page=1&limit=20&sort=add_time&order=desc
     * 查看搜索历史和条件查询
     *
     * @param info
     * @return
     */
    @RequiresPermissions("admin:history:list")
    @RequestMapping("history/list")
    public BaseRespVo list(HistoryPageInfo info) {
        CommonData<MarketSearchHistory> data = usersService.selectHistory(info);
        BaseRespVo baseRespVo = BaseRespVo.ok(data);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;
    }

    /**
     * http://182.92.235.201:8083/admin/feedback/list?page=1&limit=20&username=1&sort=add_time&order=desc&id=1
     */
    @RequiresPermissions("admin:feedback:list")
    @RequestMapping("feedback/list")
    public BaseRespVo list(FeedbackPageInfo info) {
        CommonData<WxMarketFeedback> data = usersService.selectFeedback(info);
        BaseRespVo baseRespVo = BaseRespVo.ok(data);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;

    }
}
